import SqlBuilder from './SqlBuilder'
import { TableStructCache } from './TableStructCache'

export class TableUtil {
  /**
   * 检查表是否存在
   * @param className
   */
  static async checkClassTable(rdbStore, className: string) {
    try {
      const flag = TableStructCache.tableStatusMaps.get(className)
      if (!flag) {
        const sql = SqlBuilder.getCreateTabelSql(className)
        await rdbStore.executeSql(sql)
        TableStructCache.tableStatusMaps.set(className, true)
      }
    } catch (e) {
      console.error(JSON.stringify(e))
    }
  }
}